<%@ page import="org.jeecgframework.web.system.pojo.base.PlatformVersion" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>软件版本信息</title>
    <t:base type="jquery,easyui,tools,DatePicker"></t:base>
</head>
<style type="text/css">

</style>

<script type="text/javascript">

    $(function(){

    })

</script>
<body  scroll="no" >
<t:formvalid  formid="addformobj" dialog="true" usePlugin="password" layout="table" action="platformVersionController.do?save" beforeSubmit="f_validate()">
    <input name="id" id="id" type="hidden" value="${platformVersion.id}">
    <input name="version" id="version" type="hidden" value="${platformVersion.version}">

    <table  cellpadding="0" cellspacing="1" class="formtable" id="tableId">


        <tr>
            <td align="right" style="width: 100px;">
                <label class="Validform_label">
                    版本号:
                </label>
            </td>
            <td class="value" style="width: 500px;">
                <input name="versionValid"  <c:if test="${platformVersion.id != null}">disabled="disabled" </c:if> value="0" onblur="f_validateVersion(this)" style="width:39px" class="inputxt">.
                <input name="versionValid" <c:if test="${platformVersion.id != null}">disabled="disabled" </c:if>  value="0" onblur="f_validateVersion(this)"  style="width:39px" class="inputxt">.
                <input name="versionValid" <c:if test="${platformVersion.id != null}">disabled="disabled" </c:if>  value="0" onblur="f_validateVersion(this)"  style="width:39px" class="inputxt">
                    <%--<input name="versionValid" <c:if test="${platformVersion.id != null}">disabled="disabled" </c:if>  value="0" onblur="f_validateVersion(this)" style="width:25px"  class="inputxt">--%>
                <span class="Validform_checktip" id="versionValid">请按照1.1.1.1格式填写</span>
            </td>


        </tr>
        <tr>
            <td align="right" >
                <label class="Validform_label">
                    主版本:
                </label>
            </td>
            <td class="value" >
                <input name="masterVersion" <c:if test="${platformVersion.id != null}">disabled="disabled" </c:if> type="number"  class="easyui-numberbox"  min="1" precision="1"  style="height: 25px;width: 150px;" datatype="*" id="masterVersion" value="${platformVersion.masterVersion}">
                <span class="Validform_checktip">格式1.0</span>
            </td>

        </tr>
        <tr>
            <td align="right" >
                <label class="Validform_label">
                    下载地址:
                </label>
            </td>
            <td class="value" >
                <input name="downloadAddr" datatype="*" id="downloadAddr" value="${platformVersion.downloadAddr!=null?platformVersion.downloadAddr :'http://'}" class="inputxt">
                <span class="Validform_checktip">完整下载地址，格式以http://开头</span>
            </td>


        </tr>
        <tr>
            <td align="right" >
                <label class="Validform_label">
                    软件类型:
                </label>
            </td>
            <td class="value" >

                <t:dictSelect field="softType" id="softType" typeGroupCode="softType" defaultVal="${platformVersion.softType}"
                              hasLabel="false" extendJson="{datatype='*'}" >
                </t:dictSelect>
                <span class="Validform_checktip"></span>

            </td>


        </tr>
        <tr>
            <td align="right" >
                <label class="Validform_label">
                    系统类型:
                </label>
            </td>
            <td class="value" >

                <t:dictSelect field="type" id="type" typeGroupCode="appType" defaultVal="${platformVersion.type}"
                              hasLabel="false" extendJson="{datatype='*'}" >
                </t:dictSelect>
                <span class="Validform_checktip"></span>
            </td>


        </tr>
        <tr>
            <td align="right" >
                <label class="Validform_label">
                    是否发布:
                </label>
            </td>
            <td class="value" >

                <t:dictSelect field="isable" id="isable" typeGroupCode="isno" defaultVal="${platformVersion.isable}"
                              hasLabel="false" extendJson="{datatype='*'}" >
                </t:dictSelect>
                <span class="Validform_checktip"></span>
            </td>


        </tr>
        <tr>
            <td align="right" >
                <label class="Validform_label">
                    是否强制升级:
                </label>
            </td>
            <td class="value" >

                <t:dictSelect field="upgrade" id="upgrade" typeGroupCode="isno" defaultVal="${platformVersion.upgrade}"
                              hasLabel="false" extendJson="{datatype='*'}" >
                </t:dictSelect>
                <span class="Validform_checktip"></span>
            </td>


        </tr>
        <tr>

            <td align="right">
                <label class="Validform_label">
                    更新内容:
                </label>
            </td>
            <td class="value" colspan="3">

                <textarea class="inputxt" id="content" name="content" style="height: 100px;width: 500px;" rows="3">${platformVersion.content}</textarea>

                <span class="Validform_checktip"></span>
            </td>

        </tr>
        <%--<t:authFilter name="#x222"></t:authFilter>--%>
    </table>
</t:formvalid>

</body>
<script type="text/javascript">

    $(function(){

        var va = "${platformVersion.version}";
        if(va != ""){

            var vas = va.split(".");

            for(var i = 0; i < vas.length; i++){

                $("input[name='versionValid']").get(i).value = vas[i];

            }

        }

        $("input[name='versionValid']").keyup(f_versionValid);

    });

    function f_versionValid(obj){
        if(obj.keyCode == 190 || obj.keyCode == 110){

            $(this).val($(this).val().substr(0,$(this).val().length - 1))

            f_validateVersion(this);

        }
    }

    //验证
    function f_validateVersion(obj){

        var version = $(obj).val();

        if(!version){
            $(obj).val(0);

        }

        var boo = true;

        if((/\D/g.test(version))){
            $("#versionValid").html("版本格式必须为数字！");
            $("#versionValid").addClass("Validform_wrong");
            $(obj).addClass("Validform_error");
            boo = false;
        }else{
            $("#versionValid").html("通过信息验证！");
            $("#versionValid").removeClass("Validform_wrong");
            $(obj).removeClass("Validform_error");
            $("#versionValid").addClass("Validform_right");
            boo = true;
        }

        if(boo){
            $(this).next().focus();
        }else{
            $(this).focus();
        }

        return boo;

    }

    function f_validate(){

        var version = "";

        for(var i = 0; i < $("input[name='versionValid']").length; i++){

            var boo = f_validateVersion($("input[name='versionValid']").get(i));

            if(!boo){

                return false;
            }

            version += $("input[name='versionValid']").get(i).value;
            if(i < $("input[name='versionValid']").length - 1){
                version += ".";
            }
        }

        $("#version").val(version);
        return true;

    }

</script>
</html>